//
//  XJEmoticonBtn.swift
//  新浪微博
//
//  Created by 徐绩 on 16/4/30.
//  Copyright © 2016年 ayumi. All rights reserved.
//

import UIKit

class XJEmoticonBtn: UIButton {
    
    
    var emoticon: XJEmojiModel? {
        
        didSet{
            //判断是图片表情还是emoji
            if self.emoticon?.type == "1" {
                
                self.setTitle((self.emoticon!.code! as NSString).emoji(), forState: .Normal)
                self.setImage(nil, forState: .Normal)
            }else{
                let image = UIImage(named: "\(self.emoticon!.fileName ?? "")/\(self.emoticon!.png ?? "")", inBundle: XJEmojiKeyboardViewModel.sharedEmojiViewModel.emotionBundle, compatibleWithTraitCollection: nil)
                
                self.setImage(image, forState: .Normal)
                self.setTitle(nil, forState: .Normal)
            }
        }
    }
}
